USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0013_COMISION_SEGUROSIP]    Script Date: 11/24/2011 11:34:33 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('WASP_M0013_COMISION_SEGUROSIP') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0013_COMISION_SEGUROSIP]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0013_COMISION_SEGUROSIP]    Script Date: 11/24/2011 11:34:33 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[WASP_M0013_COMISION_SEGUROSIP] AS

BEGIN
    select cs.ppsuc, cs.ppcta, cs.ppoper,
       vs.ppimp11 as cod_seg1 , cs.ppimp11 as val_seg1,
       vs.ppimp12 as cod_seg2, cs.ppimp12 as val_seg2,
       vs.ppimp13 as cod_seg3, cs.ppimp13 as val_seg3,
       vs.ppimp14 as cod_seg4, cs.ppimp14 as val_seg4,
       vs.ppimp15 as cod_seg5, cs.ppimp15 as val_seg5,
       vs.ppimp16 as cod_seg6, cs.ppimp16 as val_seg6,
       vs.ppimp17 as cod_seg7, cs.ppimp17 as val_seg7, 
       vs.ppimp18 as cod_seg8, cs.ppimp18 as val_seg8,
       vs.ppimp19 as cod_seg9, cs.ppimp19 as val_seg9
    into dbo.cabecera_comision_segurosIP
    from dbo.cabecera_valores_segurosIP as cs
        CROSS JOIN dbo.cabecera_codigos_segurosIP as vs
    where (cs.ppsuc  = vs.ppsuc) and
          (cs.ppcta  = vs.ppcta) and 
          (cs.ppoper = vs.ppoper)
    order by  vs.ppimp11

END

GO


